<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #father {
            width: 500px;
            height: 500px;
            border: 3px solid yellow;
            position: relative;
            /* 1.父元素设置display:flex */
            /* display: flex;
            justify-content: center;
            align-items: center; */
        }
        #child{
            width: 200px;
            height: 200px;
            border: 3px solid rgb(255, 217, 0);
            text-align: center;
            line-height: 200px;
            /* 子绝父相，定位全为0 */
            /* position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            margin: auto; */
            /* 子绝父相，加位移 */
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    </style>
</head>
<body>
    <div id="father">
        <div id="child">Child</div>
    </div>
</body>
</html>